<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script type="text/javascript">
$(document).ready(function(){
	allClose();
	
	$(".updateDiv .examinfo_examdate").datepicker();
});

function allClose() {
	$('.showDiv').show();
	$('.updateDiv').hide();
}

function openUpdate(examinfo_no){
	allClose();
	
	var showDiv=$('#showDiv_'+examinfo_no);
	var updateDiv=$('#updateDiv_'+examinfo_no);
	
	updateDiv.find($('.examinfo_title')).val(showDiv.find($('.examinfo_title')).text());
	updateDiv.find($('.examinfo_process')).val(showDiv.find($('.examinfo_process')).text());
	updateDiv.find($('.examinfo_question')).val(showDiv.find($('.examinfo_question')).text());
	
	updateDiv.find($('.examinfo_result[value='+showDiv.find($('.examinfo_result')).text()+']')).prop('checked', true);
	updateDiv.find($('.examinfo_level[value='+showDiv.find($('.examinfo_level')).text()+']')).prop('checked', true);
	
	updateDiv.find($('.examinfo_examdate')).val(showDiv.find($('.examinfo_examdate')).text());
	
	showDiv.hide();
	updateDiv.show();
}

function delExam(examinfo_no) {
	if(confirm("정말 삭제하시겠습니까?")){
		$.ajax({
			type:"post",
			url:"review.do",
			data:"command=deleteExaminfo&&examinfo_no="+examinfo_no,
			
			success:function(data){			
				location.reload();
			}
		});
	}
}

function updateExam(examinfo_no) {
	$('#updateForm_'+examinfo_no).submit();
}
</script>
</head>
<body>
<c:import url="my_header.jsp"/><p>
<a href="member.do?command=myReview">학과리뷰</a>
입시정보
<p>

<div>
	<c:forEach var="examReturn" items="${requestScope.examList.examinfoList}">
		<div>
			<div id="showDiv_${ examReturn.examinfo_no }" class="showDiv">
				<div class="majorunit_name">${ examReturn.majorunit.univ.univ_name }
				${ examReturn.majorunit.college.college_name }
				${ examReturn.majorunit.faculty.faculty_name }
				${ examReturn.majorunit.major.major_name }</div>
				<div class="examinfo_title">${ examReturn.examinfo_title }</div>
				<div class="examinfo_process">${ examReturn.examinfo_process }</div>
				<div class="examinfo_question">${ examReturn.examinfo_question }</div>
				<div class="examinfo_result">${ examReturn.examinfo_result }</div>
				<div class="examinfo_level">${ examReturn.examinfo_level }</div>
				<div class="examinfo_regdate">${ examReturn.examinfo_regdate }</div>
				<div class="examinfo_examdate">${ examReturn.examinfo_examdate }</div>
				<div class="examinfo_approval">
					<c:if test="${ examReturn.examinfo_approval==-1 }">승인불가</c:if>
					<c:if test="${ examReturn.examinfo_approval==0 }">승인대기</c:if>
					<c:if test="${ examReturn.examinfo_approval==1 }">승인완료</c:if>
				</div>
				
				<a href="javascript:openUpdate('${ examReturn.examinfo_no }')">수정</a>
				<a href="javascript:delExam('${ examReturn.examinfo_no }')">삭제</a>
			</div>
			<div class="updateDiv" id="updateDiv_${ examReturn.examinfo_no }">
				<form action="review.do" id="updateForm_${ examReturn.examinfo_no }" method="post">
					<input type="hidden" name="command" value="updateExaminfo">
					<input type="hidden" name="majorunit.majorunit_no" value="${ examReturn.majorunit.majorunit_no }">
					<input type="hidden" name="examinfo_no" value="${ examReturn.examinfo_no }">
					
					제목<p>
					<textarea id="examinfo_title" class="examinfo_title" name="examinfo_title" cols="40" rows="3"></textarea><p>
					과정<p>
					<textarea id="examinfo_process" class="examinfo_process" name="examinfo_process" cols="40" rows="3"></textarea><p>
					질문<p>
					<textarea id="examinfo_question" class="examinfo_question" name="examinfo_question" cols="40" rows="3"></textarea><p>
					합격여부<p>
					<input type="radio" class="examinfo_result" name="examinfo_result" value="-1">불합격
					<input type="radio" class="examinfo_result" name="examinfo_result" value="0">대기
					<input type="radio" class="examinfo_result" name="examinfo_result" value="1">합격<p>
				 	난이도<p>
					<input type="radio" class="examinfo_level" name="examinfo_level" value="1">매우 낮음
					<input type="radio" class="examinfo_level" name="examinfo_level" value="2">낮음
					<input type="radio" class="examinfo_level" name="examinfo_level" value="3">보통
					<input type="radio" class="examinfo_level" name="examinfo_level" value="4">높음
					<input type="radio" class="examinfo_level" name="examinfo_level" value="5">매우 높음<p>
				 	시험날짜
				 	<input type="text" class="examinfo_examdate" name="examinfo_examdate"><p>
				</form>
				
				<a href="javascript:updateExam('${ examReturn.examinfo_no }')">수정</a>
				<a href="javascript:allClose()">취소</a>
			</div>
		</div><br><br>
	</c:forEach>
</div>
<div>
	<c:set var="page" value="${requestScope.examList.pageManager}" />

	<c:if test="${page.currGroup==1}"><img alt="" src="../img/button/page_begin.gif"></c:if>
	<c:if test="${page.currGroup!=1}">
		<a href="member.do?command=${param.command}&&page=1"><img alt="" src="../img/button/page_begin.gif"></a>
	</c:if>

	<c:if test="${page.existOfPreviousGroup}">
		<a href="member.do?command=${param.command}&&page=${page.firstPageInCurrGroup-page.pagePerGroup}">
			<img alt="" src="../img/button/page_prev.gif"></a>
	</c:if>
	<c:if test="${!page.existOfPreviousGroup}"><img alt="" src="../img/button/page_prev.gif"></c:if>

	<c:forEach var="pageIndex" begin="${page.firstPageInCurrGroup}"
		end="${page.lastPageInCurrGroup}">
		<c:if test="${pageIndex==page.currPage}">&nbsp;<font color="#ff6d66">${pageIndex}</font>&nbsp;</c:if>
		<c:if test="${pageIndex!=page.currPage}">
			<a href="member.do?command=${param.command}&&page=${pageIndex}">&nbsp;<font color="#606060">${pageIndex}</font>&nbsp;</a>
		</c:if>
	</c:forEach>

	<c:if test="${page.existOfNextGroup}">
		<a href="member.do?command=${param.command}&&page=${page.lastPageInCurrGroup+1}">
			<img alt="" src="../img/button/page_next.gif"></a>
	</c:if>
	<c:if test="${!page.existOfNextGroup}"><img alt="" src="../img/button/page_next.gif"></c:if>

	<c:if test="${page.currGroup==page.totalGroup}"><img alt="" src="../img/button/page_end.gif"></c:if>
	<c:if test="${page.currGroup!=page.totalGroup}">
		<a href="member.do?command=${param.command}&&page=${page.totalPage}"><img alt="" src="../img/button/page_end.gif"></a>
	</c:if>
</div>

</body>
</html>